package com.mapper;

import com.bean.StudentBean;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

public interface StudentMapperByAnnotation {

    @Select("select * from t_stu where classid=#{classid}")
    public StudentBean findStuByClassid(int classid);

    @Select("select * from t_stu where stuid=#{stuid}")
    @Results({
            @Result(id = true,column = "stuid",property = "stuid"),
            @Result(column = "stuname",property = "stuname"),
            @Result(column = "grade",property = "grade"),
            @Result(column = "dept",property = "dept"),
            @Result(column = "classid",property = "clazzBean",
                    one = @One(select = "com.mapper.ClazzMapperByAnnotation.findClassByClassid"))
    })
    public StudentBean findClazzBystuno(int stuno);

    @Select("select * from t_stu where stuid in (select stuid from t_sc where cid=#{cid})")
    public StudentBean findStuByCid(Integer cid);
}
